\(\int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx\) [26]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 19, antiderivative size = 43 \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}+\frac {b^2 \sec (c+d x)}{d} \]

[Out]

-a^2*arctanh(cos(d*x+c))/d+2*a*b*arctanh(sin(d*x+c))/d+b^2*sec(d*x+c)/d

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 43, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.211, Rules used = {3598, 3855, 2686, 8} \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}+\frac {b^2 \sec (c+d x)}{d} \]

[In]

Int[Csc[c + d*x]*(a + b*Tan[c + d*x])^2,x]

[Out]

-((a^2*ArcTanh[Cos[c + d*x]])/d) + (2*a*b*ArcTanh[Sin[c + d*x]])/d + (b^2*Sec[c + d*x])/d

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2686

Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a/f, Subst[
Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n -
1)/2] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])

Rule 3598

Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Int[Expand[Sin[e
+ f*x]^m*(a + b*Tan[e + f*x])^n, x], x] /; FreeQ[{a, b, e, f}, x] && IntegerQ[(m - 1)/2] && IGtQ[n, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \int \left (a^2 \csc (c+d x)+2 a b \sec (c+d x)+b^2 \sec (c+d x) \tan (c+d x)\right ) \, dx \\ & = a^2 \int \csc (c+d x) \, dx+(2 a b) \int \sec (c+d x) \, dx+b^2 \int \sec (c+d x) \tan (c+d x) \, dx \\ & = -\frac {a^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}+\frac {b^2 \text {Subst}(\int 1 \, dx,x,\sec (c+d x))}{d} \\ & = -\frac {a^2 \text {arctanh}(\cos (c+d x))}{d}+\frac {2 a b \text {arctanh}(\sin (c+d x))}{d}+\frac {b^2 \sec (c+d x)}{d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(97\) vs. \(2(43)=86\).

Time = 1.15 (sec) , antiderivative size = 97, normalized size of antiderivative = 2.26 \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a \left (-a \log \left (\cos \left (\frac {1}{2} (c+d x)\right )\right )-2 b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+a \log \left (\sin \left (\frac {1}{2} (c+d x)\right )\right )+2 b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+b^2 \sec (c+d x)}{d} \]

[In]

Integrate[Csc[c + d*x]*(a + b*Tan[c + d*x])^2,x]

[Out]

(a*(-(a*Log[Cos[(c + d*x)/2]]) - 2*b*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] + a*Log[Sin[(c + d*x)/2]] + 2*b*
Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]]) + b^2*Sec[c + d*x])/d

Maple [A] (verified)

Time = 0.59 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.30

method result size
derivativedivides \(\frac {\frac {b^{2}}{\cos \left (d x +c \right )}+2 a b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+a^{2} \ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )}{d}\) \(56\)
default \(\frac {\frac {b^{2}}{\cos \left (d x +c \right )}+2 a b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+a^{2} \ln \left (\csc \left (d x +c \right )-\cot \left (d x +c \right )\right )}{d}\) \(56\)
risch \(\frac {2 b^{2} {\mathrm e}^{i \left (d x +c \right )}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d}-\frac {2 a b \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-1\right )}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}{d}\) \(111\)

[In]

int(csc(d*x+c)*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(b^2/cos(d*x+c)+2*a*b*ln(sec(d*x+c)+tan(d*x+c))+a^2*ln(csc(d*x+c)-cot(d*x+c)))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 102 vs. \(2 (43) = 86\).

Time = 0.29 (sec) , antiderivative size = 102, normalized size of antiderivative = 2.37 \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^{2} \cos \left (d x + c\right ) \log \left (\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) - a^{2} \cos \left (d x + c\right ) \log \left (-\frac {1}{2} \, \cos \left (d x + c\right ) + \frac {1}{2}\right ) - 2 \, a b \cos \left (d x + c\right ) \log \left (\sin \left (d x + c\right ) + 1\right ) + 2 \, a b \cos \left (d x + c\right ) \log \left (-\sin \left (d x + c\right ) + 1\right ) - 2 \, b^{2}}{2 \, d \cos \left (d x + c\right )} \]

[In]

integrate(csc(d*x+c)*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(a^2*cos(d*x + c)*log(1/2*cos(d*x + c) + 1/2) - a^2*cos(d*x + c)*log(-1/2*cos(d*x + c) + 1/2) - 2*a*b*cos
(d*x + c)*log(sin(d*x + c) + 1) + 2*a*b*cos(d*x + c)*log(-sin(d*x + c) + 1) - 2*b^2)/(d*cos(d*x + c))

Sympy [F]

\[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \csc {\left (c + d x \right )}\, dx \]

[In]

integrate(csc(d*x+c)*(a+b*tan(d*x+c))**2,x)

[Out]

Integral((a + b*tan(c + d*x))**2*csc(c + d*x), x)

Maxima [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.40 \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a b {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - a^{2} \log \left (\cot \left (d x + c\right ) + \csc \left (d x + c\right )\right ) + \frac {b^{2}}{\cos \left (d x + c\right )}}{d} \]

[In]

integrate(csc(d*x+c)*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

(a*b*(log(sin(d*x + c) + 1) - log(sin(d*x + c) - 1)) - a^2*log(cot(d*x + c) + csc(d*x + c)) + b^2/cos(d*x + c)
)/d

Giac [A] (verification not implemented)

none

Time = 0.45 (sec) , antiderivative size = 74, normalized size of antiderivative = 1.72 \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {2 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 2 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + a^{2} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) \right |}\right ) - \frac {2 \, b^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1}}{d} \]

[In]

integrate(csc(d*x+c)*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

(2*a*b*log(abs(tan(1/2*d*x + 1/2*c) + 1)) - 2*a*b*log(abs(tan(1/2*d*x + 1/2*c) - 1)) + a^2*log(abs(tan(1/2*d*x
 + 1/2*c))) - 2*b^2/(tan(1/2*d*x + 1/2*c)^2 - 1))/d

Mupad [B] (verification not implemented)

Time = 4.39 (sec) , antiderivative size = 125, normalized size of antiderivative = 2.91 \[ \int \csc (c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^2\,\ln \left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d}-\frac {2\,b^2}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1\right )}-\frac {4\,a\,b\,\mathrm {atanh}\left (\frac {16\,a^2\,b^2}{8\,a^3\,b-16\,a^2\,b^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}-\frac {8\,a^3\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{8\,a^3\,b-16\,a^2\,b^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d} \]

[In]

int((a + b*tan(c + d*x))^2/sin(c + d*x),x)

[Out]

(a^2*log(tan(c/2 + (d*x)/2)))/d - (2*b^2)/(d*(tan(c/2 + (d*x)/2)^2 - 1)) - (4*a*b*atanh((16*a^2*b^2)/(8*a^3*b
- 16*a^2*b^2*tan(c/2 + (d*x)/2)) - (8*a^3*b*tan(c/2 + (d*x)/2))/(8*a^3*b - 16*a^2*b^2*tan(c/2 + (d*x)/2))))/d